package com.example.ccj.b.c.custom.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.example.ccj.b.c.ui.TableAndViewPageBean;

import java.util.List;

/**
 * TabLayout + ViewPager2 + Fragment 实现底部栏ViewPager2的Adapter
 *
 * 2022年10月27日13:23:37
 */
public class AdapterViewPage2 extends FragmentStateAdapter {

    public List<TableAndViewPageBean> getData() {
        return data;
    }

    public void setData(List<TableAndViewPageBean> data) {
        this.data = data;
    }

    private List<TableAndViewPageBean> data;

    public AdapterViewPage2(@NonNull FragmentActivity fragmentActivity, List<TableAndViewPageBean> data) {
        super(fragmentActivity);
        this.data = data;
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        return data.get(position).getFragment();
    }

    @Override
    public int getItemCount() {
        return data.size();
    }
}